package com.springboot.shiyan2;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.event.ApplicationEventMulticaster;

@SpringBootTest()
class Demo2ApplicationTests {

    @Autowired
    ApplicationEventMulticaster eventMulticaster;

    @Test
    void testAsyncEventMulticaster() throws InterruptedException {
        eventMulticaster.multicastEvent(new AutoConfig.NoticeEvent("东莞理工学院"));
        eventMulticaster.multicastEvent(new AutoConfig.NoticeEvent("网安学院"));

        // 睡眠单元测试主线程2.1秒，避免单元测试主线程结束是异步事件的线程还没有结束二而报异常
        Thread.sleep(2100);
    }

}
